package cn.com.thinker.biz.apigw;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.netflix.zuul.filters.discovery.PatternServiceRouteMapper;
import org.springframework.context.annotation.Bean;

/**
 * 使用@EnableZuulProxy注解激活zuul。
 * @author crazyhc
 */
@SpringBootApplication
@EnableZuulProxy
public class ThinApiGWApplication {
  public static void main(String[] args) {
    SpringApplication.run(ThinApiGWApplication.class, args);
  }

  @Bean
  public PatternServiceRouteMapper serviceRouteMapper(){
    // thinker-v1服务，映射到/v1/thiner
    return new PatternServiceRouteMapper("(?<name>^.+)-(?<version>v.+$)","${version}/${name}");
  }
}
